﻿using Contione.RabbitMQ.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Contione.RabbitMQ.Demo.Controllers
{
    [Route("api/mq")]
    [ApiController]
    public class RabbitMqController : ControllerBase
    {
        private readonly IRabbitMQClient _rabbitMQClient;
        public RabbitMqController(IRabbitMQClient rabbitMQClient)
        {
            _rabbitMQClient  = rabbitMQClient;
        }

        [HttpPost("message")]
        public async ValueTask<bool> Message()
        {
             _rabbitMQClient.Send(new WeatherForecast 
             {
                 Date = DateTime.Now,
                 Summary = "",
                 TemperatureC = 0,

             }, "queue_task");

            return await new ValueTask<bool>(true);
        }
    }
}
